<template>
  <div class="login flexCenter2">
    <div class="loginForm">
      <a-form-model style="margin-bottom:30px" ref="ruleForm" :model="form" :rules="rules" labelAlign="left">
        <a-form-model-item ref="account" prop="account" style="margin-bottom:30px">
          <a-input
            v-model="form.account"
            size="large"
            placeholder="账号"
            @blur="
          () => {
            $refs.account.onFieldBlur();
          }
        "
          >
            <a-icon slot="prefix" type="user" style="color:#999" />
          </a-input>
        </a-form-model-item>

        <a-form-model-item ref="password" prop="password">
          <a-input-password
            v-model="form.password"
            size="large"
            placeholder="密码"
            @blur="
          () => {
            $refs.password.onFieldBlur();
          }
        "
          >
            <a-icon type="lock" slot="prefix" style="color:#999" />
          </a-input-password>
        </a-form-model-item>
      </a-form-model>
      <div class="flexBetween" style="margin-bottom:30px">
        <div>
          <a-checkbox @change="onChange">记住密码</a-checkbox>
        </div>
        <div style="color:#F5222D">忘记密码</div>
      </div>

      <a-button type="danger" size="large" style="width:100%" @click="login">登录</a-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
      lab0: { span: 0 },
      wrap24: { span: 24 },
      form: {
        account: '',
        password: ''
      },
      rules: {
        account: [
          {
            required: true,
            message: '请输入账号',
            trigger: 'change'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'change'
          }
        ]
      }
    }
  },
  methods: {
    login() {
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          // sessionStorage.setItem('orgId', '6f8c6758d9754e2b9eb2d74bcc312512')
          // sessionStorage.setItem('session', 'session')
          this.$router.push({ path: '/aaa' })
        } else {
          return false
        }
      })
    },
    onChange(e) {
      // console.log(`checked = ${e.target.checked}`);
      this.form.account = 'admin'
      this.form.password = 'admin'
    }
  }
}
</script>

<style scoped>
.login {
  width: 100vw;
  height: 100vh;
  /* background: dodgerblue; */
}
.loginForm {
  width: 370px;
}
</style>
